/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newkfp;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author labib.farag
 */
@Stateless
public class ExporterFacade extends AbstractFacade<Exporter> {
    @PersistenceContext(unitName = "KFPNEWPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ExporterFacade() {
        super(Exporter.class);
    }

    public List<Exporter> searchExporters(String inputValue) {
        System.out.println("//Input Value: "+inputValue);
        Query query = getEntityManager().createNamedQuery("Exporter.findByExporterNameExporterCode");
        query.setParameter("inputValue",inputValue+"%");
        List<Exporter> exporters=query.getResultList();
        System.out.println("//List Size= "+exporters.size());
        return exporters;
    }

    public Exporter findByExpoterName(String exporterName) {
        Query query = getEntityManager().createNamedQuery("Exporter.findByExporterName");
        query.setParameter("exporterName", exporterName);
        Exporter exporter = (Exporter) query.getResultList().get(0);
        return exporter;
    }
    
}
